package com.carpool;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class UserInfo {
	private String usertype="Unknow";
	private String cellphone="Unknown";
	private int uid=0;
	private String uname;
	private int chosenDriveID=0;
	private SharedPreferences uif = null;
	private Editor editor = null;
	public UserInfo(Context context) {
        this.uif = context.getSharedPreferences("PREFS_PRIVATE", Context.MODE_PRIVATE);
        this.editor = this.uif.edit();
    }
	public String getUserType() {
        if (this.uif == null) {
            return "Unknown";
        }

        this.usertype= this.uif.getString("usertype", "Unknown");
        return this.usertype;
    }
	public void setUserType(String usertype) {
        if (this.editor == null) {
            return;
        }

        this.editor.putString("usertype", usertype);
    }
	public String getCellphone() {
        if (this.uif == null) {
            return "Unknown";
        }

        this.cellphone= this.uif.getString("Cellphone", "Unknown");
        return this.cellphone;
    }
	public void setCellphone(String cellphone) {
        if (this.editor == null) {
            return;
        }

        this.editor.putString("Cellphone", cellphone);
    }
	public int getUserID() {
        if (this.uif == null) {
            return 0;
        }

        this.uid= this.uif.getInt("UserID", 0);
        return this.uid;
    }
	public void setUserID(int uid) {
        if (this.editor == null) {
            return;
        }

        this.editor.putInt("UserID", uid);
    }
	public int getChosenDriverID() {
        if (this.uif == null) {
            return 0;
        }

        this.chosenDriveID= this.uif.getInt("chosenDriveID", 0);
        return this.chosenDriveID;
    }
	public void setChosenDriverID(int chosenDriveID) {
        if (this.editor == null) {
            return;
        }

        this.editor.putInt("chosenDriveID", chosenDriveID);
    }
	public String getUsername() {
        if (this.uif == null) {
            return "Unknown";
        }

        this.uname= this.uif.getString("Username", "Unknown");
        return this.uname;
    }
	public void setUsername(String uname) {
        if (this.editor == null) {
            return;
        }

        this.editor.putString("Username", uname);
    }
	public void save() {
        if (this.editor == null) {
            return;
        }
        this.editor.commit();
    }
}
